﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using OnlineBookReader;

namespace Reader.View
{
    [DetailInfo("htmlView")]
    public partial class HtmlView : UserControl
    {
       public HtmlView()
        {
            InitializeComponent();
        }
       public HtmlView(string uri)
           : this()
        {
            CurrentUri = uri;
            navUri.Text = uri;
            if (!string.IsNullOrEmpty(CurrentUri))
            {
                viewWeb.Visibility = Visibility.Visible;
                navUri.Visibility = Visibility.Visible;
                webBrowser1.Visibility = Visibility.Visible;
             
            }
        }
        string CurrentUri;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if(Uri.IsWellFormedUriString(navUri.Text,UriKind.Absolute))
            {
                if (!string.IsNullOrEmpty(navUri.Text))
                {
                    webBrowser1.Navigate(new Uri(navUri.Text));
                }
            }
          
        }

       
        private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            webBrowser1.Height = SampleBrowser.Current.DetailInfo.ActualHeight > 40 ? SampleBrowser.Current.DetailInfo.ActualHeight - 40 : 40;
            webBrowser1.Width = SampleBrowser.Current.DetailInfo.ActualWidth > 30 ? SampleBrowser.Current.DetailInfo.ActualWidth - 30 : 30;
        }
    }
}
